﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Drawing;
using System.Drawing.Printing;
using System.Data;


namespace VSWClient.Utility
{
   public  class Printer
    {
		public Printer(DataTable dataTable)
		{
			printDataTable = dataTable;
		}
		public Printer(DataTable dataTable,List<string> batchlist)
		{
			printDataTable = dataTable;
			listBatch = batchlist;
		}
		//public Printer(DataTable dataTable, Dictionary<string,DataTable> dicBundlePipe)
		//{
		//	printDataTable = dataTable;
		//	batchPipes = dicBundlePipe;
		//}
		public Printer(DataTable dataTable, Dictionary<string, DataTable> dicBundlePipe, DataTable dicBundleTotal)
		{
			printDataTable = dataTable;
			batchPipes = dicBundlePipe;
			bundleTotal = dicBundleTotal;
		}
		#region  System.Drawing.Printing					
		#region printUtility
		int x0 = 100;//origin X coordinate
		int y0 = 20; //origin Y coordinate
		int rowHeight = 40;//the height of each line
		int columnWidthone = 220;//the widthone of each column
		int columnWidthtwo = 110;//the widthtwo of each column
		#endregion
		#region printbundle
		List<string> listBatch = new List<string>();//batchNo collection
		//DataTable dataTablebundle;//table of bundle parameters
		int batchNumsRowCount = 3;//batchnums display numbers of batchno each line
		int batchNumsRows = 0;//batchnums display total rows
		DataTable printDataTable;
		#endregion
		#region printPipe
		//DataTable dataTablePipe;//table of pipe parametrs
		#endregion
		string dataTablePipeName = "DataTablePipeName";
		string dataTablebundleName = "DataTablebundleName";
		string dataTableBundlePipeName = "DataTableBundlePipeName";
		#region printBundlePipe
		//DataTable dataTableBundlePipe;//table of pipe parameters
		Dictionary<string, int> batchPipeList;//store batchno and the numbers of pipe in each batch
		Dictionary<string, DataTable> batchPipes;//store batchno and pipes in batch
		DataTable bundleTotal;//store pipe total counts,pipe total length,pipe total weight in bundle
		#endregion		

		public void Print(bool print_mode, string printer_name, int print_num)
		{
			PrintDocument printDocument = new PrintDocument();
			if (!string.IsNullOrEmpty(printer_name))
			{
				PrinterSettings ps = new PrinterSettings();
				foreach (string str in PrinterSettings.InstalledPrinters)
				{
					if (str == printer_name)
					{
						ps.PrinterName = printer_name;
						printDocument.PrinterSettings = ps;
						break;
					}
				}
			}
			printDocument.PrintPage += PrintDocument_PrintPage;
			printDocument.PrinterSettings.Copies = (short)print_num;
			if (print_mode)
			{
				printDocument.Print();
			}
			else
			{
				PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
				printPreviewDialog.Document = printDocument;
				printPreviewDialog.PrintPreviewControl.AutoZoom = false;
				printPreviewDialog.PrintPreviewControl.Zoom = 1;
				printPreviewDialog.Document.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Default", 600, 1900);
				printPreviewDialog.ShowDialog();
			}

		}
		private void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
		{
			if (printDataTable != null || printDataTable.Rows.Count > 0)
			{
				if (printDataTable.TableName == dataTablePipeName)
				{
					PrintLabelPipe(e, printDataTable);
				}
				else if (printDataTable.TableName == dataTablebundleName)
				{
					PrintLabelBundle(e, printDataTable, listBatch);
				}
				else if (printDataTable.TableName == dataTableBundlePipeName)
				{
					PrintLabelBundlePipe(e,printDataTable);
				}
				//PrintLabel(e, "201903290001", dataTablebundle);
				//PrintLabelBundlePipe(e, dataTablebundle,listBatch);

				//PrintLabelBundlePipe(e);
			}
		}

		public void PrintLabel(PrintPageEventArgs e, string bundle_code, DataTable dataTable)
		{
			Pen pen = new Pen(Color.Black, 1f);
			Font font = new Font("宋体", 12, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
			//画bundlecode
			System.Drawing.Point pointtitlename = new System.Drawing.Point(100, 100);
			System.Drawing.Point pointtitlevalue = new System.Drawing.Point(220, 100);
			e.Graphics.DrawString("Bundle code:", font, new SolidBrush(System.Drawing.Color.Black), pointtitlename);
			e.Graphics.DrawString(bundle_code, font, new SolidBrush(System.Drawing.Color.Black), pointtitlevalue);
			//画线
			e.Graphics.DrawLine(pen, 100, 120, 320, 120);
			//画pipecode列名
			System.Drawing.Point pointpipename = new System.Drawing.Point(100, 125);
			System.Drawing.Point pointweight = new System.Drawing.Point(220, 125);
			e.Graphics.DrawString("Pipe code", font, new SolidBrush(System.Drawing.Color.Black), pointpipename);
			e.Graphics.DrawString("Pipe weight", font, new SolidBrush(System.Drawing.Color.Black), pointweight);
			//画pipecode值
			for (int i = 0; i < dataTable.Rows.Count; i++)
			{
				System.Drawing.Point pointpipecode = new System.Drawing.Point(100, 145 + i * 20);
				System.Drawing.Point pointweightvalue = new System.Drawing.Point(220, 145 + i * 20);
				e.Graphics.DrawString(dataTable.Rows[i]["Pipe_id"].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointpipecode);
				e.Graphics.DrawString(dataTable.Rows[i]["Weight"].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointweightvalue);
			}
		}
		public void PrintLabelBundle(PrintPageEventArgs e, DataTable dataTable, List<string> batchList)
		{
			Pen pen = new Pen(Color.Black, 1f);
			Font font = new Font("宋体", 12, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
			//画线
			if (listBatch.Count % batchNumsRowCount == 0)
			{
				batchNumsRows = listBatch.Count / batchNumsRowCount;
			}
			else
			{
				batchNumsRows = listBatch.Count / batchNumsRowCount + 1;
			}

			for (int i = 0; i < 12; i++)
			{
				if (i < 7)
				{
					e.Graphics.DrawLine(pen, x0, y0 + i * rowHeight, x0 + 2 * columnWidthone, y0 + i * rowHeight);
				}
				else
				{
					e.Graphics.DrawLine(pen, x0, y0 + (i + batchNumsRows - 1) * rowHeight, x0 + 2 * columnWidthone, y0 + (i + batchNumsRows - 1) * rowHeight);
				}
			}
			for (int i = 0; i < 3; i++)
			{
				e.Graphics.DrawLine(pen, x0 + i * columnWidthone, y0, x0 + i * columnWidthone, y0 + (10 + batchNumsRows) * rowHeight);
			}
			e.Graphics.DrawLine(pen, x0 + columnWidthtwo, y0 + rowHeight, x0 + columnWidthtwo, y0 + 2 * rowHeight);
			e.Graphics.DrawLine(pen, x0 + 3 * columnWidthtwo, y0 + rowHeight, x0 + 3 * columnWidthtwo, y0 + 2 * rowHeight);
			e.Graphics.DrawLine(pen, x0 + columnWidthtwo, y0 + (9 + batchNumsRows) * rowHeight, x0 + columnWidthtwo, y0 + (10 + batchNumsRows) * rowHeight);
			e.Graphics.DrawLine(pen, x0 + 3 * columnWidthtwo, y0 + (9 + batchNumsRows) * rowHeight, x0 + 3 * columnWidthtwo, y0 + (10 + batchNumsRows) * rowHeight);
			//画dataTable列名
			System.Drawing.Point pointBundleIdName = new System.Drawing.Point(x0 + 50, y0 + 20);
			System.Drawing.Point pointBundleIdValue = new System.Drawing.Point(x0 + 240, y0 + 20);
			e.Graphics.DrawString(dataTable.Columns[0].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointBundleIdName);
			e.Graphics.DrawString(dataTable.Rows[0][0].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointBundleIdValue);

			System.Drawing.Point pointDateName = new System.Drawing.Point(x0 + 35, y0 + 60);
			System.Drawing.Point pointDateValue = new System.Drawing.Point(x0 + 125, y0 + 60);
			e.Graphics.DrawString(dataTable.Columns[1].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointDateName);
			e.Graphics.DrawString(dataTable.Rows[0][1].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointDateValue);

			System.Drawing.Point pointTimeName = new System.Drawing.Point(x0 + 245, y0 + 60);
			System.Drawing.Point pointTimeValue = new System.Drawing.Point(x0 + 355, y0 + 60);
			e.Graphics.DrawString(dataTable.Columns[2].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointTimeName);
			e.Graphics.DrawString(dataTable.Rows[0][2].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointTimeValue);

			for (int i = 0; i < 4; i++)
			{
				System.Drawing.Point pointname = new System.Drawing.Point(x0 + 50, y0 + 100 + i * 40);
				System.Drawing.Point pointvalue = new System.Drawing.Point(x0 + 240, y0 + 100 + i * 40);
				e.Graphics.DrawString(dataTable.Columns[i + 3].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointname);
				e.Graphics.DrawString(dataTable.Rows[0][i + 3].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointvalue);
			}

			System.Drawing.Point pointBatchNumbersname = new System.Drawing.Point(x0 + 50, y0 + 220 + batchNumsRows * 40);
			e.Graphics.DrawString(dataTable.Columns[7].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointBatchNumbersname);
			List<string> listValues = new List<string>();
			for (int i = 0; i < batchNumsRows; i++)
			{
				if (i == batchNumsRows - 1)
				{
					if (listBatch.Count % batchNumsRowCount == 1)
					{
						listValues.Add(listBatch[i * batchNumsRowCount]);
					}
					else if (listBatch.Count % batchNumsRowCount == 2)
					{
						listValues.Add(listBatch[i * batchNumsRowCount] + ";" + listBatch[i * batchNumsRowCount + 1]);
					}
					else
					{
						listValues.Add(listBatch[i * batchNumsRowCount] + ";" + listBatch[i * batchNumsRowCount + 1] + ";" + listBatch[i * batchNumsRowCount + 2]);
					}
				}
				else
				{
					listValues.Add(listBatch[i * batchNumsRowCount] + ";" + listBatch[i * batchNumsRowCount + 1] + ";" + listBatch[i * batchNumsRowCount + 2]);
				}
			}
			for (int i = 0; i < batchNumsRows; i++)
			{
				System.Drawing.Point pointBatchNumbersvalue = new System.Drawing.Point(x0 + 240, y0 + 220 + (i + 1) * 40);
				e.Graphics.DrawString(listValues[i], font, new SolidBrush(System.Drawing.Color.Black), pointBatchNumbersvalue);
			}

			for (int i = 0; i < 3; i++)
			{
				System.Drawing.Point pointname = new System.Drawing.Point(x0 + 50, y0 + 300 + i * 40);
				System.Drawing.Point pointvalue = new System.Drawing.Point(x0 + 240, y0 + 300 + i * 40);
				e.Graphics.DrawString(dataTable.Columns[i + 8].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointname);
				e.Graphics.DrawString(dataTable.Rows[0][i + 8].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointvalue);
			}

			System.Drawing.Point pointShiftName = new System.Drawing.Point(x0 + 35, y0 + 420);
			System.Drawing.Point pointShiftValue = new System.Drawing.Point(x0 + 125, y0 + 420);
			e.Graphics.DrawString(dataTable.Columns[11].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointShiftName);
			e.Graphics.DrawString(dataTable.Rows[0][11].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointShiftValue);

			System.Drawing.Point pointCradleName = new System.Drawing.Point(x0 + 245, y0 + 420);
			System.Drawing.Point pointCradleValue = new System.Drawing.Point(x0 + 355, y0 + 420);
			e.Graphics.DrawString(dataTable.Columns[12].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointCradleName);
			e.Graphics.DrawString(dataTable.Rows[0][12].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointCradleValue);
		}
		public void PrintLabelPipe(PrintPageEventArgs e, DataTable dataTable)
		{
			Pen pen = new Pen(Color.Black, 1f);
			Font font = new Font("宋体", 12, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
			//画线			
			for (int i = 0; i < 12; i++)
			{
				e.Graphics.DrawLine(pen, x0, y0 + i * rowHeight, x0 + 2 * columnWidthone, y0 + i * rowHeight);
			}
			for (int i = 0; i < 3; i++)
			{
				e.Graphics.DrawLine(pen, x0 + i * columnWidthone, y0, x0 + i * columnWidthone, y0 + 11 * rowHeight);
			}
			e.Graphics.DrawLine(pen, x0 + columnWidthtwo, y0 + rowHeight, x0 + columnWidthtwo, y0 + 2 * rowHeight);
			e.Graphics.DrawLine(pen, x0 + 3 * columnWidthtwo, y0 + rowHeight, x0 + 3 * columnWidthtwo, y0 + 2 * rowHeight);
			//画dataTable列名
			System.Drawing.Point pointBundleIdName = new System.Drawing.Point(x0 + 50, y0 + 20);
			System.Drawing.Point pointBundleIdValue = new System.Drawing.Point(x0 + 240, y0 + 20);
			e.Graphics.DrawString(dataTable.Columns[0].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointBundleIdName);
			e.Graphics.DrawString(dataTable.Rows[0][0].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointBundleIdValue);

			System.Drawing.Point pointDateName = new System.Drawing.Point(x0 + 35, y0 + 60);
			System.Drawing.Point pointDateValue = new System.Drawing.Point(x0 + 125, y0 + 60);
			e.Graphics.DrawString(dataTable.Columns[1].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointDateName);
			e.Graphics.DrawString(dataTable.Rows[0][1].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointDateValue);

			System.Drawing.Point pointTimeName = new System.Drawing.Point(x0 + 245, y0 + 60);
			System.Drawing.Point pointTimeValue = new System.Drawing.Point(x0 + 355, y0 + 60);
			e.Graphics.DrawString(dataTable.Columns[2].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointTimeName);
			e.Graphics.DrawString(dataTable.Rows[0][2].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointTimeValue);

			for (int i = 0; i < 9; i++)
			{
				System.Drawing.Point pointname = new System.Drawing.Point(x0 + 50, y0 + 100 + i * 40);
				System.Drawing.Point pointvalue = new System.Drawing.Point(x0 + 240, y0 + 100 + i * 40);
				e.Graphics.DrawString(dataTable.Columns[i + 3].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointname);
				e.Graphics.DrawString(dataTable.Rows[0][i + 3].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointvalue);
			}


		}
		public void PrintLabelBundlePipe(PrintPageEventArgs e, DataTable dataTable)
		{
			Pen pen = new Pen(Color.Black, 1f);
			Font font = new Font("宋体", 12, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
			for (int i = 0; i < 7; i++)
			{
				e.Graphics.DrawLine(pen, x0, y0 + i * rowHeight, x0 + 2 * columnWidthone, y0 + i * rowHeight);
			}
			e.Graphics.DrawLine(pen, x0 + columnWidthtwo, y0 + rowHeight, x0 + columnWidthtwo, y0 + 2 * rowHeight);
			e.Graphics.DrawLine(pen, x0 + 3 * columnWidthtwo, y0 + rowHeight, x0 + 3 * columnWidthtwo, y0 + 2 * rowHeight);
			for (int i = 0; i < 3; i++)
			{
				e.Graphics.DrawLine(pen, x0 + i * columnWidthone, y0, x0 + i * columnWidthone, y0 + 6 * rowHeight);
			}
			e.Graphics.DrawLine(pen, x0 + columnWidthtwo, y0 + (9 + batchNumsRows) * rowHeight, x0 + columnWidthtwo, y0 + (10 + batchNumsRows) * rowHeight);
			e.Graphics.DrawLine(pen, x0 + 3 * columnWidthtwo, y0 + (9 + batchNumsRows) * rowHeight, x0 + 3 * columnWidthtwo, y0 + (10 + batchNumsRows) * rowHeight);

			System.Drawing.Point pointBundleIdName = new System.Drawing.Point(x0 + 50, y0 + 20);
			System.Drawing.Point pointBundleIdValue = new System.Drawing.Point(x0 + 240, y0 + 20);
			e.Graphics.DrawString(dataTable.Columns[0].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointBundleIdName);
			e.Graphics.DrawString(dataTable.Rows[0][0].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointBundleIdValue);

			System.Drawing.Point pointDateName = new System.Drawing.Point(x0 + 35, y0 + 60);
			System.Drawing.Point pointDateValue = new System.Drawing.Point(x0 + 125, y0 + 60);
			e.Graphics.DrawString(dataTable.Columns[1].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointDateName);
			e.Graphics.DrawString(dataTable.Rows[0][1].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointDateValue);

			System.Drawing.Point pointTimeName = new System.Drawing.Point(x0 + 245, y0 + 60);
			System.Drawing.Point pointTimeValue = new System.Drawing.Point(x0 + 355, y0 + 60);
			e.Graphics.DrawString(dataTable.Columns[2].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointTimeName);
			e.Graphics.DrawString(dataTable.Rows[0][2].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointTimeValue);

			for (int i = 0; i < 4; i++)
			{
				System.Drawing.Point pointname = new System.Drawing.Point(x0 + 50, y0 + 100 + i * 40);
				System.Drawing.Point pointvalue = new System.Drawing.Point(x0 + 240, y0 + 100 + i * 40);
				e.Graphics.DrawString(dataTable.Columns[i + 3].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointname);
				e.Graphics.DrawString(dataTable.Rows[0][i + 3].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointvalue);
			}
			y0 += 6 * rowHeight;

			//int btotalCount = 0;
			//int btotalLength = 0;
			//int btotalWeight = 0;
			foreach (KeyValuePair<string, DataTable> kv in batchPipes)
			{
				for (int i = 1; i <= (kv.Value.Rows.Count-1 + 3); i++)
				{
					e.Graphics.DrawLine(pen, x0, y0 + i * rowHeight, x0 + 2 * columnWidthone, y0 + i * rowHeight);
				}
				//DataRow[] dr = dataTable.Select(dataTable.Columns[7].ColumnName + " = '" + p.Key + "' ");
				System.Drawing.Point pointBatchName = new System.Drawing.Point(x0 + 50, y0 + 20);
				System.Drawing.Point pointBatchValue = new System.Drawing.Point(x0 + 240, y0 + 20);
				e.Graphics.DrawString("Batch No", font, new SolidBrush(System.Drawing.Color.Black), pointBatchName);
				e.Graphics.DrawString(kv.Key, font, new SolidBrush(System.Drawing.Color.Black), pointBatchValue);

				System.Drawing.Point pointPipeIdName = new System.Drawing.Point(x0 + 35, y0 + 60);
				System.Drawing.Point pointLengthName = new System.Drawing.Point(x0 + 125, y0 + 60);
				System.Drawing.Point pointWeightName = new System.Drawing.Point(x0 + 245, y0 + 60);
				System.Drawing.Point pointDefectName = new System.Drawing.Point(x0 + 335, y0 + 60);
				e.Graphics.DrawString(kv.Value.Columns[0].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointPipeIdName);
				e.Graphics.DrawString(kv.Value.Columns[1].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointLengthName);
				e.Graphics.DrawString(kv.Value.Columns[2].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointWeightName);
				e.Graphics.DrawString(kv.Value.Columns[3].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointDefectName);

				//int totalCount = kv.Value.Rows.Count;
				//int totalLength = 0;
				//int totalWeight = 0;
				for (int i = 0; i < kv.Value.Rows.Count; i++)
				{					
					System.Drawing.Point pointPipeIdValue = new System.Drawing.Point(x0 + 15, y0 + 60 + (i + 1) * rowHeight);
					System.Drawing.Point pointLengthValue = new System.Drawing.Point(x0 + 125, y0 + 60 + (i + 1) * rowHeight);
					System.Drawing.Point pointWeightValue = new System.Drawing.Point(x0 + 245, y0 + 60 + (i + 1) * rowHeight);
					System.Drawing.Point pointDefectValue = new System.Drawing.Point(x0 + 355, y0 + 60 + (i + 1) * rowHeight);
					e.Graphics.DrawString(kv.Value.Rows[i][kv.Value.Columns[0].ColumnName].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointPipeIdValue);
					e.Graphics.DrawString(kv.Value.Rows[i][kv.Value.Columns[1].ColumnName].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointLengthValue);
					e.Graphics.DrawString(kv.Value.Rows[i][kv.Value.Columns[2].ColumnName].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointWeightValue);
					e.Graphics.DrawString(kv.Value.Rows[i][kv.Value.Columns[3].ColumnName].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointDefectValue);
				}
				//System.Drawing.Point pointTotalCountValue = new System.Drawing.Point(x0 + 35, y0 + 100 + totalCount * rowHeight);
				//System.Drawing.Point pointTotalLengthValue = new System.Drawing.Point(x0 + 125, y0 + 100 + totalCount * rowHeight);
				//System.Drawing.Point pointTotalWeightValue = new System.Drawing.Point(x0 + 245, y0 + 100 + totalCount * rowHeight);
				//e.Graphics.DrawString("total:" + totalCount.ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointTotalCountValue);
				//e.Graphics.DrawString(totalLength.ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointTotalLengthValue);
				//e.Graphics.DrawString(totalWeight.ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointTotalWeightValue);
				//btotalCount += totalCount;
				//btotalLength += totalLength;
				//btotalWeight += totalWeight;

				e.Graphics.DrawLine(pen, x0 + columnWidthtwo, y0 + rowHeight, x0 + columnWidthtwo, y0 + (kv.Value.Rows.Count + 2) * rowHeight);
				e.Graphics.DrawLine(pen, x0 + 3 * columnWidthtwo, y0 + rowHeight, x0 + 3 * columnWidthtwo, y0 + (kv.Value.Rows.Count + 2) * rowHeight);
				for (int i = 0; i < 3; i++)
				{
					e.Graphics.DrawLine(pen, x0 + i * columnWidthone, y0, x0 + i * columnWidthone, y0 + (kv.Value.Rows.Count + 2) * rowHeight);
				}
				y0 += (kv.Value.Rows.Count + 2) * rowHeight;
			}

			e.Graphics.DrawLine(pen, x0, y0 + 2 * rowHeight, x0 + 2 * columnWidthone, y0 + 2 * rowHeight);
			e.Graphics.DrawLine(pen, x0, y0 + 5 * rowHeight, x0 + 2 * columnWidthone, y0 + 5 * rowHeight);
			e.Graphics.DrawLine(pen, x0, y0 + 6 * rowHeight, x0 + 2 * columnWidthone, y0 + 6 * rowHeight);

			System.Drawing.Point pointBTotalCountName1 = new System.Drawing.Point(x0 + 15, y0 + 10);
			System.Drawing.Point pointBTotalLengthName1 = new System.Drawing.Point(x0 + 115, y0 + 10);
			System.Drawing.Point pointBTotalWeightName1 = new System.Drawing.Point(x0 + 225, y0 + 10);
			System.Drawing.Point pointBTotalCountName2 = new System.Drawing.Point(x0 + 15, y0 + 25);
			System.Drawing.Point pointBTotalLengthName2 = new System.Drawing.Point(x0 + 125, y0 + 25);
			System.Drawing.Point pointBTotalWeightName2 = new System.Drawing.Point(x0 + 225, y0 + 25);
			System.Drawing.Point pointBTotalCountValue = new System.Drawing.Point(x0 + 35, y0 + 50);
			System.Drawing.Point pointBTotalLengthValue = new System.Drawing.Point(x0 + 125, y0 + 50);
			System.Drawing.Point pointBTotalWeightValue = new System.Drawing.Point(x0 + 245, y0 + 50);

			e.Graphics.DrawString("bundle pipe", font, new SolidBrush(System.Drawing.Color.Black), pointBTotalCountName1);
			e.Graphics.DrawString("bundle pipe", font, new SolidBrush(System.Drawing.Color.Black), pointBTotalLengthName1);
			e.Graphics.DrawString("bundle pipe", font, new SolidBrush(System.Drawing.Color.Black), pointBTotalWeightName1);
			e.Graphics.DrawString(bundleTotal.Columns[0].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointBTotalCountName2);
			e.Graphics.DrawString(bundleTotal.Columns[1].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointBTotalLengthName2);
			e.Graphics.DrawString(bundleTotal.Columns[2].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointBTotalWeightName2);
			e.Graphics.DrawString("total:" + bundleTotal.Rows[0][bundleTotal.Columns[0].ColumnName].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointBTotalCountValue);
			e.Graphics.DrawString(bundleTotal.Rows[0][bundleTotal.Columns[1].ColumnName].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointBTotalLengthValue);
			e.Graphics.DrawString(bundleTotal.Rows[0][bundleTotal.Columns[2].ColumnName].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointBTotalWeightValue);


			System.Drawing.Point pointShiftName = new System.Drawing.Point(x0 + 35, y0 + 220);
			System.Drawing.Point pointShiftValue = new System.Drawing.Point(x0 + 125, y0 + 220);
			e.Graphics.DrawString(dataTable.Columns[11].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointShiftName);
			e.Graphics.DrawString(dataTable.Rows[0][11].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointShiftValue);

			System.Drawing.Point pointCradleName = new System.Drawing.Point(x0 + 245, y0 + 220);
			System.Drawing.Point pointCradleValue = new System.Drawing.Point(x0 + 355, y0 + 220);
			e.Graphics.DrawString(dataTable.Columns[12].ColumnName, font, new SolidBrush(System.Drawing.Color.Black), pointCradleName);
			e.Graphics.DrawString(dataTable.Rows[0][12].ToString(), font, new SolidBrush(System.Drawing.Color.Black), pointCradleValue);

			e.Graphics.DrawLine(pen, x0, y0, x0, y0 + 6 * rowHeight);
			e.Graphics.DrawLine(pen, x0 + 2 * columnWidthone, y0, x0 + 2 * columnWidthone, y0 + 6 * rowHeight);

			e.Graphics.DrawLine(pen, x0 + columnWidthtwo, y0, x0 + columnWidthtwo, y0 + 2 * rowHeight);
			e.Graphics.DrawLine(pen, x0 + 2 * columnWidthtwo, y0, x0 + 2 * columnWidthtwo, y0 + 2 * rowHeight);
			e.Graphics.DrawLine(pen, x0 + 3 * columnWidthtwo, y0, x0 + 3 * columnWidthtwo, y0 + 2 * rowHeight);
			e.Graphics.DrawLine(pen, x0 + columnWidthtwo, y0 + 5 * rowHeight, x0 + columnWidthtwo, y0 + 6 * rowHeight);
			e.Graphics.DrawLine(pen, x0 + 2 * columnWidthtwo, y0 + 5 * rowHeight, x0 + 2 * columnWidthtwo, y0 + 6 * rowHeight);
			e.Graphics.DrawLine(pen, x0 + 3 * columnWidthtwo, y0 + 5 * rowHeight, x0 + 3 * columnWidthtwo, y0 + 6 * rowHeight);

		}
		#endregion
	}
}
